// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';
import { TableListItem } from './data';

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
 const result = await request('/api/mjBanner/queryByPage', {
    method: 'POST',
    data: {
      ...params,
    },
    ...(options || {}),
  });
  return { data: result.data.records, success: true,total:result.data.total  }
}

/** 新建规则 PUT /api/rule */
export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/mjBanner/edit', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/mjBanner/add', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}
export async function prOnOff(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/mjBanner/edit', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}


/** 删除规则 DELETE /api/rule */
export async function removeRule(data: { id: number }, options?: { [key: string]: any }) {
  console.log(data,options);
  return request<Record<string, any>>('/api/mjBanner/delete', {
    params:data,
    method: 'POST',
    ...(options || {}),
  });
}

export async function upload(data:FormData){
  return request('/api/MjUploadFiles/picture', {
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data
  });
}